<template>
    <div>
        <input v-model="name" type="text" @keyup.enter="sonMethod" />
    </div>
</template>

<script>
export default {
    data() {
        return {
            name: ''
        }
    },
    emits: ['addStudent'],// 为了代码提示和协同开发
    methods: {
        sonMethod() {
            console.log('into appson1.vue sonMethod');
            this.$emit('addStudent', this.name); // 把name值传递给组件自定义事件addStudent
            this.name = '';
        }
    },
}
</script>